Dashboard Temp Share Shortlinks Frames API

HTMLify

Maximum Nesting Depth Of The Parentheses.cpp
Views: 1 | Author: cody
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
int maxDepth(string s) {
	// Write your code here.
	int n = s.length();
	int count; 
	int close;
	int maxi = 0;
	for(int i =0; i<n; i++){
		if(s[i] == '('){
			count ++;
		}
		maxi= max(count,maxi);
		if(s[i] == ')'){
			count--;
		}
		
	}
	if(count == close){
		return maxi;
	}
	
}